package com.zkthink.ceres.applet;

import com.zkthink.security.annotation.EnableLoginArgResolver;
import com.zkthink.validator.config.EnableFormValidator;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * https://mp.weixin.qq.com/s/zkxI5IQP0jFTjVYe5pTsXw EnableAspectJAutoProxy(proxyTargetClass=true,
 * exposeProxy=true) 配合 @EnableCaching 才能解决在同一个类中通过 AopContext.currentProxy() 调用时，使缓存生效
 *
 * @author ceres
 * @createTime 2018-01-13 1:34
 */
@SpringBootApplication
@Configuration
@Slf4j
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
@EnableFormValidator
@ComponentScan({"com.zkthink"})
@MapperScan({"com.zkthink.*.dao", "com.zkthink.ceres.*.dao","com.zkthink.zhl.*.dao","com.zkthink.ceres.**.mapper"})
@EnableAsync
public class AppLetApplication {

  public static void main(String[] args) throws UnknownHostException {
    ConfigurableApplicationContext application = SpringApplication.run(AppLetApplication.class, args);
    Environment env = application.getEnvironment();
    log.info("\n----------------------------------------------------------\n\t" +
            "应用 '{}' 运行成功! 访问连接:\n\t" +
            "Swagger文档: \t\thttp://{}:{}{}/doc.html\n\t" +
            "数据库监控: \t\thttp://{}:{}{}/druid\n" +
            "----------------------------------------------------------",
        env.getProperty("spring.application.name"),
        InetAddress.getLocalHost().getHostAddress(),
        env.getProperty("server.port"),
        env.getProperty("server.servlet.context-path"),
        "127.0.0.1",
        env.getProperty("server.port"),
        env.getProperty("server.servlet.context-path"));
  }
}
